package com.example.controller;

import com.example.service.PoetryService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@RestController
@CrossOrigin
public class Calculate_Page_Controller {
    @Resource
    private PoetryService poetryService;
    @GetMapping("/calculate_poetry")//页面添加
    public void add_page() {
        if(poetryService.check_column()==null){//判断该字段是否已存在
            poetryService.add_column_num();
        }
        for(int i=0;i<poetryService.select_area().size()-1;i++){
            String code=poetryService.select_area().get(i);
            if(code.endsWith("0000")){
                poetryService.add_num(code,poetryService.locate_all_poetry(Integer.parseInt(code.substring(0,2))).size());
            }
            else if(!code.equals("")){//地区编码非空
                poetryService.add_num(code,poetryService.locate_and_poetry(Integer.parseInt(code)).size());
            }
        }
        poetryService.delete_area();//去除脏数据
    }
}
